﻿using System;
using System.Web.UI;
using Telerik.Web.UI;

/// <summary>
/// 页面基类
/// </summary>
public class RadBasePageEx : Page
{
    #region 脚本相关辅助方法
    /// <summary>
    /// 向页面添加脚本
    /// </summary>
    /// <param name="script">脚本</param>
    protected void AddScript(string script)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), DateTime.Now.Ticks.ToString(), script, true);
    }

    /// <summary>
    /// 在页面中弹出消息框
    /// </summary>
    /// <param name="message">消息</param>
    protected void RadAlert(string message)
    {
        AddScript(string.Format("radalert('{0}', 280, 100);", message.Replace("'", "\'")));
    }

    /// <summary>
    /// 向页面添加脚本
    /// (使用RadAjaxManager情况下)
    /// </summary>
    /// <param name="script">脚本</param>
    protected void AddScriptM(string script)
    {
        RadAjaxManager.GetCurrent(this).ResponseScripts.Add(script);
    }

    /// <summary>
    /// 在页面中弹出消息框
    /// (使用RadAjaxManager情况下)
    /// </summary>
    /// <param name="message">消息</param>
    protected void RadAlertM(string message)
    {
        AddScriptM(string.Format("radalert('{0}', 280, 100);", message.Replace("'", "\'")));
    }
    #endregion
}